#include "image.h"

Image::Image(){}

Image::Image(Mat img)
{
    image = img.clone();
    imageSource = img.clone();
}

Image::~Image()
{
    image.release();
    imageSource.release();
}

Mat Image::getImage()
{
//    Mat img = image(Rect(select.left(), select.top(), select.right(), select.bottom())).clone();
    return image;
}

void Image::addShape(DrawShape shape)
{
    if(shape.getType()==ROI)
    {
        Roi = shape;
    }
    else
    {
        shapes.append(shape);
    }
    qDebug() << "Shape ajouté";
}

QList<DrawShape> Image::getShapes()
{
    return shapes;
}

QImage Image::getQImage(Mat image)
{
    // OpenCV Mat -> Qt QImage
    return QImage((uchar*) image.data, image.cols, image.rows, image.step, QImage::Format_RGB888);
}
